var frequencyTextbox;
var urlTextbox;
var nameTextbox;

function init() {	
	$('#mainDefinition').empty();
	$('#footer').empty();
	$('#header').empty();
	
	if(storageGet('definitionList') != ""){
		$.each(
			storageGet('definitionList').split('|').sort(),
			function(intIndex, element){
				$('#mainDefinition').append(getDefinitionSection(element));
			}
		);
	}
	
	$('select#frequency').val(storageGet('frequency'));
	insertCommonUI();
}


function getDefinitionSection(element){
	return $('<div></div>')
		.addClass('section')
		.append($('<div></div>')
			.addClass("section-header")
			.append($('<div></div>')
				.addClass('nameBlock')
				.append(element))
			.append($('<div></div>')
				.addClass('definitionBlock')
				.append("Definition : ")
				.append(getOptionInputText(element + '-definition')
					.addClass('definitionInput'))
				.append("&nbsp;&nbsp;&nbsp;&nbsp;Frequency : ")
				.append($('<span></span>')
							.addClass('frequencyInput')
							.append(getMessageFromTime(storageGet(element + '-frequency')))))
				.append($('<span></span>')
					.click(function(){
						remove(element);
					})
					.append($('<img src="delete.gif" />')
						.attr("title","Delete this element")
						.addClass('delete')))
				.append($('<span></span>')
					.click(function(){
						reset(element, init);
					})
					.append($('<img src="reset.png" />')
					.attr("title","Reset the frequency of this element")
						.addClass('reset'))));
		
}


